'use strict';

const db = uniCloud.database()
const _table = 'mwj';

exports.main = async (event, context) => {
	//event为客户端上传的参数
	console.log('event : ', event.action)
	// console.log('context : ', context)
	switch (event.action) {
		case 'getList':
			var collection = db.collection(_table)
			var row = await collection.get({
				getCount: true //如需查询数据总条数
			})

			console.log('res', row.data)
			if (row.data) {
				return {
					code: 0,
					data: row.data
				}
			}
			return {
				error: 1,
					message: "数据不存在"
			}
			break;

	}
};
